﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fastyou.WCF.Contracts;
using System.ServiceModel;

namespace Fastyou.WCF.ServiceLib
{
    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]
    public class NoneSession:INoneSession
    {
        private int _result = 0;

        public NoneSession()
        {
            Console.WriteLine("the object has been created.");
        }

        //~NoneSession()
        //{
        //    Console.WriteLine("the object has been closed.");
        //}
        #region INoneSession Members

        public void Add(int x)
        {
            string sessionid = OperationContext.Current==null ?"":OperationContext.Current.SessionId.ToString();
            Console.WriteLine("add method,the sessionid:{0}",sessionid);
            _result += x;

        }

        public string getResult()
        {
            string sessionid = OperationContext.Current == null ? "" : OperationContext.Current.SessionId.ToString();
            Console.WriteLine("add getResult,the sessionid:{0}", sessionid);
            return _result.ToString();
        }

        #endregion
    }
}
